using ASP;
using HoWave.Common;
using HoWave.Web.Shop;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Mall_Message : Shop, IRequiresSessionState
{
	protected Repeater Repeater1;
	protected TextBox ContentBox;
	protected PlaceHolder PlaceHolder1;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.MessageDataBind();
		}
	}
	public void MessageDataBind()
	{
		this.Repeater1.DataSource = this.conn.GetDataSet("select * from HLMall_Message order by CreateTime desc");
		this.Repeater1.DataBind();
		this.PlaceHolder1.Visible = false;
	}
	protected void SeeContent_Click(object sender, EventArgs e)
	{
		LinkButton linkButton = sender as LinkButton;
		RepeaterItem repeaterItem = linkButton.Parent as RepeaterItem;
		HiddenField hiddenField = (HiddenField)repeaterItem.FindControl("HiddenID");
		DataTable dataTable = this.conn.GetDataTable("select Content from HLMall_Message where MessageID=" + int.Parse(hiddenField.Value));
		if (dataTable != null && dataTable.Rows.Count > 0)
		{
			this.ContentBox.Text = dataTable.Rows[0]["Content"].ToString();
			this.PlaceHolder1.Visible = true;
		}
		dataTable.Dispose();
	}
	protected void lbtDel_Click(object sender, EventArgs e)
	{
		int num = 0;
		LinkButton linkButton = sender as LinkButton;
		RepeaterItem repeaterItem = linkButton.Parent as RepeaterItem;
		HiddenField hiddenField = (HiddenField)repeaterItem.FindControl("HiddenID");
		try
		{
			num = this.conn.Execute("delete HLMall_Message where MessageID=" + int.Parse(hiddenField.Value));
		}
		catch (Exception ex)
		{
			ex.WriteErrorLog(new string[]
			{
				"正常操作"
			});
			num = 0;
		}
		if (num > 0)
		{
			this.MessageDataBind();
		}
	}
	protected void Butdel_Click(object sender, EventArgs e)
	{
		int num = 0;
		string text = "";
		for (int i = 0; i < this.Repeater1.Items.Count; i++)
		{
			CheckBox checkBox = (CheckBox)this.Repeater1.Items[i].FindControl("CheckBox1");
			HiddenField hiddenField = (HiddenField)this.Repeater1.Items[i].FindControl("HiddenID");
			if (checkBox.Checked)
			{
				text = text + hiddenField.Value + ",";
			}
		}
		try
		{
			num = this.conn.Execute("delete HLMall_Message where MessageID in(" + text.Substring(0, text.Length - 1) + ")");
		}
		catch (Exception ex)
		{
			ex.WriteErrorLog(new string[]
			{
				"正常操作"
			});
			num = 0;
		}
		if (num > 0)
		{
			this.MessageDataBind();
		}
	}
	protected void Allselect_Click(object sender, EventArgs e)
	{
		for (int i = 0; i < this.Repeater1.Items.Count; i++)
		{
			CheckBox checkBox = (CheckBox)this.Repeater1.Items[i].FindControl("CheckBox1");
			checkBox.Checked = true;
		}
	}
	protected void NotSelect_Click(object sender, EventArgs e)
	{
		for (int i = 0; i < this.Repeater1.Items.Count; i++)
		{
			CheckBox checkBox = (CheckBox)this.Repeater1.Items[i].FindControl("CheckBox1");
			checkBox.Checked = false;
		}
	}
}
